#include "custom_progress_bar.h"

CustomProgressBar::CustomProgressBar(QWidget *parent) : QProgressBar(parent), progressValue(0.0)
{
    setStyleSheet("QProgressBar { border: 1px solid black; text-align: center; color: transparent; }"
                  "QProgressBar::chunk { background-color: #EEEAD9; }");
}

void CustomProgressBar::setDoubleValue(double value)
{
    progressValue = value;
    setValue(static_cast<int>(value * 100));
}

void CustomProgressBar::paintEvent(QPaintEvent *event)
{
    QProgressBar::paintEvent(event);
    QPainter painter(this);
    QString text = QString::number(progressValue * 100, 'f', 3);
    QFont font = painter.font();
    font.setBold(true);
    painter.setFont(font);
    painter.setPen(Qt::black);
    painter.drawText(rect(), Qt::AlignCenter, text + "%");
}
